package test1;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Test {

    public static void main(String[] args) {
        try {
            InetAddress[] inetAddresses = InetAddress.getAllByName("www.baidu.com");
            for (int i = 0; i <inetAddresses.length ; i++) {
                System.out.println("地址是:"+inetAddresses[i].getHostAddress()+"\n主机名是:"+inetAddresses[i].getHostName());
            }
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
